package com.colorlight.cloud.gateway.service.impl;


import com.colorlight.cloud.all_event.AllProtocolType;
import com.colorlight.cloud.gateway.api.message.constraint.schedule.ScheduleActions;
import com.colorlight.cloud.gateway.service.PublishStrategy;
import com.colorlight.cloud.xm.entity.enumerate.NameStruct;
import com.google.gson.Gson;
import org.springframework.stereotype.Component;


/**
 * @author Demon
 * @date 22/3/2024  下午3:39
 */
@Component
public class Xm implements PublishStrategy {
	@Override
	public String strategyType() {
		return AllProtocolType.NAME_STRUCT_XM.getType();
	}
	
	
	@Override
	public ScheduleActions getScheduleActions(String type, String json) {
		Class<? extends ScheduleActions> aClass = this.getScheduleActionsClass(type);
		Gson gson = new Gson();
		return gson.fromJson(json, aClass);
	}
	
	@Override
	public Class<? extends ScheduleActions> getScheduleActionsClass(String type) {
		return NameStruct.valueOf(type).getAClass();
	}
	
	
}
